# -*- coding: utf-8 -*-
"""
file:ch2_symbol模块表达极限
author: Fuwen
time: 2022/7/15 7:17
software:PyCharm
"""
# limit(函数, variable, point)
# float('inf)  或者 oo --无穷

from sympy import *

x = Symbol('x')
f = 58 * (1/2)**x  # 酒精浓度稀释的函数
res1 = limit(f, x, float('inf'))
res2 = limit(f, x, oo)
print('limit(f, x, float("inf")) = {}'.format(res1))
print('limit(f, x, oo) = {}'.format(res2))

#%%
# 倒数的函数 f = 1 / x
x = Symbol('x')
f = 1 / x
right_to_zero = limit(f, x, 0, dir='+')
left_to_zero = limit(f, x, 0, dir='-')
print('左边逼近于0，函数极限= {}'.format(left_to_zero))
print('右边逼近于0，函数极限= {}'.format(right_to_zero))

